#ifndef SMALLBLOCK_H
#define SMALLBLOCK_H

#include <QWidget>
#include <QLineEdit>

namespace Ui {
class SmallBlock;
}

class VolueControl;

class SmallBlock : public QWidget
{
    Q_OBJECT
    
public:
    explicit SmallBlock(int type=1, QWidget *parent = 0);
    ~SmallBlock();

    void setLineEditPlaceHolder(const QString& txt);
    void setLineEditReadOnly(bool r);
    void setSelectionList(QStringList &list, QString df="");

    void setTitleLabel(QString txt);
    void setText(const QString &txt);
    QString getText();
    void setLineEditValidator(QString regstr);
    int getCursorPos();

    void setBlockEnable(bool s);

    void setVol(int vol);
    int getVol();
    void changeOption();
    void setOption(int index);  //在初次设置时使用

    int getNextIndex();

    int mtype() const;
    void setmType(int type);

    QLineEdit * lineEdit();

signals:
    void selctionChanged(QString);

    void optionChangeSig(int);
    void volChangedSig(int);
    void textStartSig();
    void textFinishedSig(QString);
    void receiveEnter();

protected:
    void focusInEvent(QFocusEvent *e);
    void focusOutEvent(QFocusEvent *e);
    void keyReleaseEvent(QKeyEvent *e);
    void mouseReleaseEvent(QMouseEvent *e);
    bool eventFilter(QObject *, QEvent *);
    
private:
    Ui::SmallBlock *ui;
    int m_type;         //0：lineedit; 1：combox;
    QMap<int,QString> m_selectionMap;
    int m_current;
    int m_vol;
    QString m_text;
    VolueControl *m_volctrl;
    int cursorpos;
};

#endif // SMALLBLOCK_H
